package com.xjy.web.controller.controller;

import com.xjy.common.annotation.Log;
import com.xjy.common.annotation.RepeatSubmit;
import com.xjy.common.core.controller.BaseController;
import com.xjy.common.core.domain.AjaxResult;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.enums.BusinessType;
import com.xjy.common.utils.poi.ExcelUtil;
import com.xjy.system.domain.bo.ReportContractExecuteQueryBo;
import com.xjy.system.domain.vo.ReportContractExecuteVo;
import com.xjy.system.service.IReportContractExecuteService;
import com.xjy.system.service.IReportContractResultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 合同执行报告Controller
 *
 * @author mlb
 * @date 2022-03-10
 */
@Api(value = "合同执行报告控制器", tags = {"合同执行报告管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/report_contract_execute")
public class ReportContractExecuteController extends BaseController {

    private final IReportContractExecuteService iReportContractExecuteService;
    /**
     * 查询合同执行报告列表
     */
    @ApiOperation("查询合同执行报告列表")
    @PreAuthorize("@ss.hasPermi('system:report_contract_execute:list')")
    @GetMapping("/list")
    public TableDataInfo<ReportContractExecuteVo> list(@Validated ReportContractExecuteQueryBo bo) {
        return iReportContractExecuteService.queryPageList(bo);
    }

    /**
     * 导出合同执行报告列表
     */
    @ApiOperation("导出合同执行报告列表")
    @PreAuthorize("@ss.hasPermi('system:report_contract_execute:export')")
    @Log(title = "合同执行报告", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ReportContractExecuteVo> export(@Validated ReportContractExecuteQueryBo bo) {
        List<ReportContractExecuteVo> list = iReportContractExecuteService.queryList(bo);
        ExcelUtil<ReportContractExecuteVo> util = new ExcelUtil<ReportContractExecuteVo>(ReportContractExecuteVo.class);
        return util.exportExcel(list, "合同执行报告");
    }

    /**
     * 获取合同执行报告详细信息
     */
    @ApiOperation("获取合同执行报告详细信息")
    @PreAuthorize("@ss.hasPermi('system:report_contract_execute:query')")
    @GetMapping("/{projId}")
    public AjaxResult<ReportContractExecuteVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("projId") Long projId) {
        return AjaxResult.success(iReportContractExecuteService.queryById(projId));
    }

}
